package se.statemachine.fsm.mvcstyle;

import javax.swing.JFrame;

import se.statemachine.fsm.interfacestyle.TurnstileFSM;
import se.statemachine.fsm.mvcstyle.impl.ModelImpl;
import se.statemachine.fsm.mvcstyle.impl.ViewImpl;

public class Main {

	public static void main(String[] args) {
		
		Controller controller = new Controller();		
		ModelImpl model = new ModelImpl();
		ViewImpl view = new ViewImpl();
		view.setActionListener(controller);
		TurnstileFSM fsm = new TurnstileFSM();
									
		controller.setView(view);
		controller.setModel(model);
		controller.setTurnstileFsm(fsm);
		
		controller.initComponent();
				
		createAndShowGUI(view);
	}

	private static void createAndShowGUI(ViewImpl newContentPane) {

		// Create and set up the window.
		JFrame frame = new JFrame("TurnstileDemo");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// Create and set up the content pane.		 
		newContentPane.setOpaque(true); // content panes must be opaque
		frame.setContentPane(newContentPane);

		// Display the window.
		frame.pack();
		frame.setVisible(true);
	}
}
